<script type="text/javascript">
<!--
function checkForm() {
    spanError = document.getElementById('error');
    var checkRegExp = new RegExp("^[ \t]*$");
    var checkRegExpMail = new RegExp("^\\w[\\w+\.\-]*@[\\w\-]+\.\\w[\\w+\.\-]*\\w$", "gi");
    if (document.user.users_login.value.length == 0
        || checkRegExp.test(document.user.users_login.value)) {
        spanError.innerHTML = "<?php echo T_('Login empty.'); ?>";
        spanError.className = "usvn_error";
        return false;
    }
    <?php if (!isset($this->user) || !$this->user->id) : ?>
        if ((!document.user.users_password.value.length || !document.user.users_password2.value.length)) {
            spanError.innerHTML = "<?php echo T_('Password empty.');?>";
            spanError.className = "usvn_error";
            return false;
        }
        if (document.user.users_password.value.length < 8 && (!document.user.users_id ||
            document.user.users_password.value.length >= 1)) {
            spanError.innerHTML = "<?php echo T_('Password incorrect (need more 8 characters).');?>";
            spanError.className = "usvn_error";
            return false;
        }
        if (document.user.users_password.value != document.user.users_password2.value) {
            spanError.innerHTML = "<?php echo T_('Password incorrect (not the same).');?>";
            spanError.className = "usvn_error";
            return false;
        }
    <?php endif; ?>
    if (document.user.users_email.value.length != 0
        && !checkRegExpMail.test(document.user.users_email.value)) {
        spanError.innerHTML = "<?php echo T_('Email incorrect.');?>";
        spanError.className = "usvn_error";
        return false;
    }
    spanError.innerHTML = '';
    spanError.className = "";
    return true;
}
function showform() {
    var form = '<div style="position:absolute;text-align:center;padding:10px;border:1px gray solid;background-color:white;height:100px;width:150px;"><div id="autogeneratedpw" style="padding:5px;height:20px;width:125px;border:1px gray solid;margin-bottom:10px"></div><input type="button" value="閉じる" onclick="closeform()" style="width:60px" /><input type="button" value="再生成" onclick="genpw()" style="width:60px" /><div><input type="button" value="入力欄にコピー" onclick="copypw()" style="width:115px" /></div></div>';
    document.getElementById("genform").innerHTML = form;
    genpw();
}

function copypw() {
    var pw = document.getElementById("autogeneratedpw").innerText;
    document.getElementById("users_password").value = pw;
    document.getElementById("users_password2").value = pw;
}

function closeform() {
    document.getElementById("genform").innerHTML = "";
}

function genpw() {
    var s = new Array("ABCDEFGHJKLMNPQRSTUVWXYZ", "abcdefghijkmnpqrstuvwxyz", "23456789", "!?#$%&()*+-/<=>.,@[]{}_", "", "");
    for (i = 0; i < 5; i++) s[4] += randstr(s, i);
    for (i = 0; i < 6; i++) randstr(s, 4);
    document.getElementById("autogeneratedpw").innerText = s[5];
}

function randstr(s, i) {
    var t;
    s[5] += t = s[i].charAt(Math.floor(Math.random() * s[i].length));
    return s[i] = s[i].replace(t, "");
}

-->
</script>
